<template>
	<view :style="{ height: this.app_height + 'rpx' }" style="background-color: #f3f4f6;">
		<scroll-view style="height: 100%;" v-if="show">
			<view class="u-flex u-row-left u-p-l-50 u-p-b-60 u-type-primary-bg" style="padding-top: 100rpx;">
				<u-avatar size="large"></u-avatar>
				<u-icon class="u-margin-left-25" name="edit-pen" :label="userinfo.talentName" label-pos="left" size="34"
					label-size="34" color="#FFFFFF" label-color="#FFFFFF" @click="tapUserinfo"></u-icon>
			</view>
			<u-card :show-head="false" :showFoot="false" :border="false" padding="0">
				<view slot="body">
					<u-cell-group :border="false">
						<u-cell-item center title="账号管理" arrow @click="tapAccountManager">
						</u-cell-item>
						<u-cell-item center title="个人资料" arrow @click="tapUserinfo">
						</u-cell-item>
						<u-cell-item center title="我的项目" arrow @click="tapProjectlist">
						</u-cell-item>
						<u-cell-item center title="入队申请" arrow @click="tapJoin">
						</u-cell-item>
						<u-cell-item center title="受邀申请" arrow @click="tapInvite">
						</u-cell-item>
						<u-cell-item center title="关于" arrow @click="tapAbout">
						</u-cell-item>
					</u-cell-group>
				</view>


			</u-card>
		</scroll-view>
		<u-tabbar :list="$store.state.tabbars" activeColor="#2979ff" mid-button></u-tabbar>
	</view>
</template>

<script>
	export default {
		async onLoad() {
			uni.getSystemInfo({
				success: res => {
					this.app_height = (res.windowHeight - 50) / (res.windowWidth / 750);
				}
			});
			var [err, res] = await this.$to(this.$api.get({
				url: "/userinfo/get",
				loading: false
			}));
			this.userinfo = res.data;
			this.show = true;
		},
		data() {
			return {
				app_height: 0,
				userinfo: null,
				show: false
			}
		},
		methods: {
			tapUserinfo() {
				uni.navigateTo({
					url: "../my/update_userinfo",
					events: {
						savedUserinfo: res => {
							this.userinfo = res;
						}
					},
					success: (res) => {
						res.eventChannel.emit('userinfo', this.userinfo);
					}
				});
			},
			tapAccountManager() {
				uni.navigateTo({
					url: "../my/account_manager"
				});
			},
			tapAbout() {
				uni.navigateTo({
					url: "../my/about"
				});
			},
			tapProjectlist() {
				uni.navigateTo({
					url: "../my/project_list"
				});
			},
			tapInvite() {
				uni.navigateTo({
					url: "../my/invite"
				});
			},
			tapJoin() {
				uni.navigateTo({
					url: "../my/join"
				});
			}
		}
	}
</script>

<style>

</style>
